//
//  BAKit_LocationVC.m
//  BAKit
//
//  Created by 孙博岩 on 2018/9/26.
//  Copyright © 2018 boai. All rights reserved.
//

#import "BAKit_LocationVC.h"
#import "BAKit_LocationVC+ThirdNavi.h"
#pragma mark - 获取当前定位信息 封装
#import "BAKit_LocationManager.h"

@interface BAKit_LocationVC ()

@property(nonatomic, strong)  BAKit_LocationManager *location;

@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (strong, nonatomic) MKMapView *mapView;

- (IBAction)handleButtonActions:(UIButton *)sender;

@end

@implementation BAKit_LocationVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)ba_base_setupUI
{
//    self.location = BAKit_LocationManager.shared;
//    BAKit_WeakSelf
//    self.location.getCurrentLocationBlock = ^(CLPlacemark *place) {
//        BAKit_StrongSelf
////        NSString *msg = [NSString stringWithFormat:@"当前地址：\n\n%@\n\n%@\n\n%@\n\n%@\n\n%@\n\n%@\n\n", place.country, place.administrativeArea, place.locality, place.subLocality, place.subThoroughfare, place.name];
//        
////        NSLog(msg);
//        //self.textView.text = msg;
////
////    cityName:上海市,longitude:121.433407,latitude:31.352465
//        NSString *locality = @"上海市";
//        CGFloat longitude = 121.433407;//place.location.coordinate.longitude;
//        CGFloat latitude = 31.352465;//place.location.coordinate.latitude;
//        NSString *address = [NSString stringWithFormat:@"cityName:%@,longitude:%f,latitude:%f",
//                             locality,
//                             longitude,
//                             latitude];
//        NSLog(address);
//        //[self toThirdNavi:place];
//    };
//    self.location.refuseToUsePositioningSystemBlock = ^(NSString *message) {
//        BAKit_StrongSelf
//        NSString *msg = [NSString stringWithFormat:@"当前状态：%@", message];
//        
//        NSLog(msg);
//        self.textView.text = msg;
//    };
}

//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    [self.location ba_loaction_start];
//}

- (MKMapView *)mapView{
    if (_mapView == nil) {
        _mapView = [MKMapView new];
        [self.view addSubview:_mapView];
        //_mapView mas
    }
    return _mapView;
}

- (IBAction)handleButtonActions:(UIButton *)sender
{
    if (sender.tag == 0)
    {
        //[self.location ba_loaction_start];
        //    cityName:上海市,longitude:121.433407,latitude:31.352465
        NSString *locality = @"上海市";
        CGFloat longitude = 121.333407;//place.location.coordinate.longitude;
        CGFloat latitude = 31.202465;//place.location.coordinate.latitude;
        NSString *address = [NSString stringWithFormat:@"cityName:%@,longitude:%f,latitude:%f",
                             locality,
                             longitude,
                             latitude];
        NSLog(address);
        [self toThirdNavi:longitude :latitude];
    }
    else if (sender.tag == 1)
    {
        [self.location ba_loaction_stop];
    }
}
@end
